﻿@{
    ViewData["Title"] = "栏目管理";
    Layout = "~/Areas/Manager/Views/Shared/_Layout.cshtml";
}

<script src="~/manager/js/jquery.min.js"></script>
<link href="~/manager/css/ztree/metroStyle.css" rel="stylesheet" />
<script src="~/manager/js/ztree/jquery.ztree.all.js"></script>

<div class="layui-card height-95">
    <div class="layui-card-header">
        <p>栏目分类</p>
    </div>
    <div class="layui-card-body">
        <div id="treeDemo" class="ztree">

        </div>
        <div class="layui-form-item btn-fix-b">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit onclick="SaveDate()" type="button">确定</button>
                <button id="close" type="button" class="layui-btn layui-btn-primary">关闭</button>
            </div>
        </div>
    </div>
</div>
@section scriptsfeet
    {
    <script type="text/javascript">

        layui.config({
            base: '/layuiadmin/' //自定义模块路径
        }).use(['form', 'layer', 'sykjwh'], function () {
            var $ = layui.$, form = layui.form, sykjwh = layui.sykjwh;

            $("#close").click(function () {
                sykjwh.close();
            });
        });

        var zTree;

        //设置树插件的各种参数
        var treeDemo = {
            async: {
                //是否开启异步请求
                enable: true,
                url: "@Url.Action("GetChannelTreeList", "cms", new {area = Constant.AREAMANAGER})"
            },
            data: {
                //简单数据格式
                simpleData: {
                    enable: true
                }
            },
            //回调事件
            callback: {
                //点击事件
                onClick: function(event, treeId, treeNode) {
                    zTree.checkNode(treeNode, !treeNode.checked, true);
                    $(window.parent.document).find("#channelId").val(treeNode.id);
                    $(window.parent.document).find("#channelName").val(treeNode.name);
                },
                onAsyncSuccess: function(event, treeId, treeNode, msg) { //异步成功回调
                    var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
                    treeObj.expandAll(true); //展开全部节点
                }
            }
        };

        //初始化
        $(function init () {
            zTree = $.fn.zTree.init($("#treeDemo"), treeDemo);
        });

        function SaveDate() {
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);
        }
    </script>
}